fix(posthog): move session recording proxy to middleware for large payload support#3065
Merged
waleedlatif1 merged 1 commit intostagingfrom Jan 29, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…yload support Next.js rewrites can strip request bodies for large payloads (1MB+), causing 400 errors from CloudFront. PostHog session recordings require up to 64MB per message. Moving the proxy to middleware ensures proper body passthrough. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
8863da8 to
781929e
Compare
Contributor
Greptile OverviewGreptile SummaryMoved PostHog session recording proxy from Next.js rewrites to middleware to fix 400 errors on large payloads (1MB+), and fixed React hooks violations in credential selector components by using Key Changes:
Technical Details:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as PostHog Client
participant Middleware as Next.js Middleware (proxy.ts)
participant PostHog as PostHog US Server
Note over Client,PostHog: Before (Next.js Rewrites)
Client->>Middleware: POST /ingest/s (1MB+ payload)
Note over Middleware: Rewrite at routing layer
Middleware->>PostHog: Forward to us.i.posthog.com
PostHog-->>Middleware: 400 Error (payload too large)
Middleware-->>Client: 400 Error
Note over Client,PostHog: After (Middleware Proxy)
Client->>Middleware: POST /ingest/s (1MB+ payload)
Note over Middleware: Handle in middleware runtime<br/>with streaming support
Middleware->>PostHog: Rewrite to us.i.posthog.com<br/>with correct headers
PostHog-->>Middleware: 200 Success
Middleware-->>Client: 200 Success
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/ingest/sfor large session recording payloads (1MB+)Type of Change
Testing
Tested manually - deploy to preview and verify
/ingest/srequests return 200Checklist